package cn.swjtuhc.ss.hljapi.controller;

import cn.swjtuhc.ss.hljapi.common.Result;
import cn.swjtuhc.ss.hljapi.pojo.Viewer;
import cn.swjtuhc.ss.hljapi.service.ViewerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 程序狗没有春天
 * @version 1.00
 * @createTime 2024/9/2 13:46
 */
@Slf4j
@RequestMapping("/api")
@RestController
public class ViewerController {
    @Autowired
    ViewerService viewerService;
    @GetMapping("/viewers")
    public Result viewers() {
        Viewer byId = viewerService.getById(1);
        byId.setViewers(byId.getViewers()+1);
        viewerService.updateById(byId);
        return Result.success(byId);
    }
}
